package com.chance.cc.crawler.development.scripts.qimai;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;

import java.sql.Timestamp;
import java.util.TimeZone;

/**
 * @ClassName song
 * @Description TODO
 * @Author ding
 * @Date 2021/9/8 16:09
 * @Version 1.0
 **/
public class Text {


    public static void main(String[] args) {
        Text t = new Text();
        //String android = t.android();
        String s = t.appStore();
        JSONObject jsonObject = JSONObject.parseObject(s);
        String baseUrl = jsonObject.getString("baseUrl");
        System.out.println(jsonObject);
        System.out.println(baseUrl);
        StringBuffer sb = new StringBuffer(String.valueOf(System.currentTimeMillis())).insert(10,".");
        System.out.println(sb);
    }

   public String android(){
       JsonObject e = new JsonObject();
       JsonObject params = new JsonObject();
       String baseUrl = "https://api.qimai.cn";
       String url = "/andapp/getCommentList";
       String appid = "7797760";
       String market = "9";
       e.addProperty("baseUrl",baseUrl);
       e.addProperty("url",url);
       params.addProperty("appid",appid);
       params.addProperty("market",market);
       e.add("params",params);
       String s  = e.toString();
       return s;
   }
   public String  appStore(){
       JsonObject e = new JsonObject();
       JsonObject params = new JsonObject();
       String baseUrl = "https://api.qimai.cn";
       long current=System.currentTimeMillis();//当前时间毫秒数
       long zero=current/(1000*3600*24)*(1000*3600*24)- TimeZone.getDefault().getRawOffset();//今天零点零分零秒的毫秒数
       long twelve=zero+24*60*60*1000-1;//今天23点59分59秒的毫秒数
       String sdate1 = String.valueOf(new Timestamp(zero));
       String sdate = sdate1.substring(0,sdate1.length()-2);//今天零点零分零秒的毫秒数
       String edate1 = String.valueOf(new Timestamp(twelve));
       String edate = edate1.substring(0,edate1.length()-4);//今天23点59分59秒的毫秒数
       String url = "/app/comment";
       String appid = "1570277888";
       String country = "cn";
       String sword = "";
       e.addProperty("baseUrl",baseUrl);
       e.addProperty("url",url);
       params.addProperty("appid",appid);
       params.addProperty("country",country);
       params.addProperty("sword",sword);
       params.addProperty("sdate",sdate);
       params.addProperty("edate",edate);
       e.add("params",params);
       String s = e.toString();
       return  s;
   }

/*
* var cdd = "{\"baseUrl\":\"https://api.qimai.cn\",\"params\":{\"country\":\"cn\",\"sword\":\"\",\"sdate\":\"2021-09-08 00:00:00\",\"appid\":\"1570277888\",\"edate\":\"2021-09-08 23:59:59\"},\"url\":\"/app/comment\"}\n";
 var cdb= "{\"baseUrl\":\"https://api.qimai.cn\",\"params\":{\"market\":\"9\",\"appid\":\"7797760\"},\"url\":\"/andapp/getCommentList\"}";
* */
}
